#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @author: zzll0909
# @file: 9.py
# @time: 2022/11/09
# @software: VS Code

class Solution:
    def isPalindrome(self, x: int) -> bool:
        result = False
        # 0必是回文
        if x == 0:
            result = True
        # 只处理个位不为零的正数，其他必不是回文
        elif x > 0 and x % 10 != 0:
            reversed = 0
            while x > reversed:
                reversed = reversed * 10 + x % 10
                x //= 10
            # 分别处理偶数位数和奇数位数
            if reversed == x or reversed // 10 == x:
                result = True
        return result


if __name__ == "__main__":
    x = 121
    solu = Solution()
    result = solu.isPalindrome(x)
    print(result)
